<?php
class Training_TableController extends Zendvn_Controller_Action{
	
	//Tham so 
	protected $_arrParam;
	
	public function init(){
		$this->_arrParam = $this->_request->getParams();
	}
	
	public function find2Action(){
		$tblGroup = new Training_Model_UserGroup();
		$rowSet = $tblGroup->fetchAll('id <25');
		$row3 = $rowSet->seek(3-1)->current();
		echo '<pre>';
		print_r($row3);
		echo '</pre>';
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function infoAction(){
		$tblGroup = new Training_Model_UserGroup();
		$info = $tblGroup->info('cols');
		echo '<pre>';
		print_r($info);
		echo '</pre>';
		
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function updateAction(){
		$tblGroup = new Training_Model_UserGroup();
		//$result = $tblGroup->saveItem(null,array('task'=>'update'));
		$tblGroup->saveItem(null,array('task'=>'fetch2'));
		
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function getAction(){
		$tblGroup = new Training_Model_UserGroup();
		$result = $tblGroup->getItem();
		
		echo '<pre>';
		print_r($result);
		echo '</pre>';
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function saveAction(){
		$tblGroup = new Training_Model_UserGroup();
		
		//$tblGroup->saveItem();
		
		//$tblGroup->saveItem(null,array('task'=>'fetch'));
		$tblGroup->saveItem(null,array('task'=>'insert'));
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function deleteAction(){
		$tblGroup = new Training_Model_UserGroup();
		//$tblGroup->deleteItem();
		$tblGroup->deleteItem(null,array('task'=>'multi'));
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function findAction(){
		$tblGroup = new Training_Model_UserGroup();
		$result = $tblGroup->find(4)->current()->toArray();
		//$row = $result->current()->toArray();
		echo '<pre>';
		print_r($result);
		echo '</pre>';
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function indexAction(){
		echo '<pre>';
		print_r($this->_arrParam);
		echo '</pre>';
		$tblGroup = new Training_Model_UserGroup();
		$rowSet = $tblGroup->fetchAll();
		echo '<pre>';
		print_r($rowSet->toArray());
		echo '</pre>';
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function listAction(){
		$tblGroup = new Training_Model_UserGroup();
		//$result = $tblGroup->listItem();
		
		//$result = $tblGroup->listItem(null,array('task'=>'group-default'));
		//$result = $tblGroup->listItem($this->_arrParam,array('task'=>'group-default-2'));
		
		//$result = $tblGroup->listItem($this->_arrParam,array('task'=>'order'));
		$result = $tblGroup->listItem($this->_arrParam,array('task'=>'limit'));
		echo '<pre>';
		print_r($result);
		echo '</pre>';
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	
}